<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.laputa.service.model.BuildData"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
	<head>
		<base href="<%=basePath%>">
		<title>GroundID = ${groundID}, UserID = ${userID}</title>
		<link rel="stylesheet" type="text/css" href="css/main.css">
	</head>
<body background="pic/background.jpg">

<table id="banner" width="100%">
	<tr>
		<td align="center">
			<img src="pic/head.jpg" width="1000" height="100" hspace="100">
		</td>
    </tr>
</table>

<table id="banner" width="100%">
	<tr>
		<td align="right">
			<form method="post" action="login.do">
				<input type="submit" name="home" value="返回" />
			</form>
		</td>
    </tr>
</table>
 
<table>
	<tr>
		<%
			BuildData buildData = (BuildData) request.getAttribute("buildData");
			
			String groundID = (String) pageContext.findAttribute("groundID");
			
			int i = 1;
			for (long type: buildData.getTypes())  
			{
				long price = buildData.getPrice(type);
				if (i++ % 2 == 0)
				{
					out.print("<table>");	
				}else
				{
					out.print("<table align=\"left\" valign=\"top\">");
				}
				out.print("<tr>");
					out.print("<td align=\"center\">");
						out.print("<table width=\"35%\" border=\"1\" cellspacing=\"0\">");
							out.print("<img src=\"buildings/building" + type + ".png\" width=\"350\" height=\"240\" hspace=\"130\">");
							out.print("<tr>");
								out.print("<td class=\"menu\">");
									out.print("<td align=\"center\">  建造费用 " + price + "</td>");
									out.print("<form method =\"post\" action=\"build.do\">");
										out.print("<input type=\"hidden\" name=\"groundID\" value=\"" + groundID + "\"/>");
										out.print("<input type=\"hidden\" name=\"buildingType\" value =\"" + type + "\"/>");
										out.print("<input type=\"hidden\" name=\"price\" value=\"" + price + "\"/>");
										out.print("<td><input align=\"center\" type = \"submit\" name = \"build\" value = \"建造\"/></td>");
									out.print("</form>");
								out.print("</td>");
							out.print("</tr>");
							out.print("</table>");
					out.print("</td>");
				out.print("</tr>");
				out.print("</table>");
			}
		%>
	</tr>
</table>

</body>
</html>
